﻿using UnityEngine;
using System.Collections;

public class CameraFollow : MonoBehaviour
{
    public GameObject target;
    public float height;
    public float distance;
    public float lerpSpeed = 5f;

    private Vector3 pos;
	
	private void Awake () 
	{
        pos = transform.position;
	}
	
	private void LateUpdate ()
	{
        //transform.position = new Vector3(target.transform.position.x, 
        //    target.transform.position.y + height,
        //    target.transform.position.z - distance);
        pos.x = Mathf.Lerp(pos.x, target.transform.position.x, Time.deltaTime * lerpSpeed);
        //pos.x = 0;
        pos.y = Mathf.Lerp(pos.y, target.transform.position.y + height, Time.deltaTime * lerpSpeed);
        pos.z = Mathf.Lerp(pos.z, target.transform.position.z - distance, Time.deltaTime * lerpSpeed);
        transform.position = pos;
	}
}
